<style type="text/css">
	table.table-orders
	{
		border-collapse:collapse;
		border:1px solid #aeaeae; 
		margin-left:20px;
	}
	
	table.table-orders tr
	{
		border:1px solid #aeaeae;
		height:35px;
	}
	
	table.table-orders tr:hover
	{
		background-color:#f3f3f3;
	}
	
	table.table-orders tr.table-header
	{
		font-weight:bold;
		text-align:center;
		height:45px;
		font-size:16px;
		color:#44320f;
		background-color:#dadada;
	}
	
	table.table-orders tr.table-header:hover
	{
		background-color:#dadada;
	}
	
	table.table-orders tr.table-footer
	{
		font-weight:bold;
		height:40px;
		font-size:16px;
		color:#44320f;
		background-color:#f3f3f3;
	}
	
	table.table-orders tr.table-footer:hover
	{
	}
	
	table.table-orders td
	{
		border:1px solid #aeaeae;
		padding:2px;
	}
	
	.notice
	{
		margin-bottom:0px;
		margin-top:5px;
	}
</style>
<?php
	$code = $_GET['code'];
	if($code != '')
	{
		$esc_arr = $exec_mysql->escape_string(array($code));
		$query = sprintf("update orders set view = 1 where code = '%s'", $esc_arr[0]);
		$exec_mysql->execute($query, 0);
		$query = sprintf("select * from orders where code = '%s'", $esc_arr[0]);
		$result = $exec_mysql->execute($query, 0);
		while($row = mysql_fetch_array($result))
		{
			echo '<table class="form-layout">';
			echo '<tr><td>Mã đơn đặt hàng:</td><td><b>'.$row['code'].'</b></td></tr>';
			echo '<tr><td>Tên khách hàng:</td><td><b>'.$row['full_name'].'</b></td></tr>';
			echo '<tr><td>Số điện thoại:</td><td><b>'.$row['phone'].'</b></td></tr>';
			echo '<tr><td>Email:</td><td><b>'.$row['email'].'</b></td></tr>';
			echo '<tr><td>Địa chỉ:</td><td><b>'.$row['address'].'</b></td></tr>';
			echo '<tr><td>Yêu cầu thêm:</td><td><i>'.$row['contact'].'</i></td></tr>';
			echo '</table>';
		}
		$query = sprintf("select id_product, quantity, code, name, price from orders_detail, product where id_product = product.id and orders_code = '%s'", $esc_arr[0]);
		$result = $exec_mysql->execute($query, 0);
		$index = 1;
		$total_money = 0;
		echo '<table width="90%" class="table-orders">';
		echo '<tr class="table-header"><td><b>STT</b></td><td><b>Mã tranh</b></td><td><b>Tên tranh</b></td><td><b>Số lượng</b></td><td><b>Đơn giá</b><sup>(VNĐ)</sup></td><td><b>Thành tiền</b><sup>(VNĐ)</sup></td></tr>';
		while($row = mysql_fetch_array($result))
		{
			echo '<tr>';
			echo '<td align="center">'.$index.'</td>';
			echo '<td>'.$row['code'].'</td>';
			echo '<td>'.$row['name'].'</td>';
			echo '<td align="right">'.$row['quantity'].'</td>';
			echo '<td align="right">'.$global->format_number($row['price'], 0).'</td>';
			$money = $row['price']*$row['quantity'];
			$total_money += $money;
			echo '<td align="right">'.$global->format_number($money, 0).'</td>';
			echo '</tr>';
			$index++;
		}
		echo '<tr class="table-footer"><td colspan="5" align="right">Tổng tiền*</td><td align="right" >'.$global->format_number($total_money, 0).'</td></tr>';
		echo '</table>';
	}
?>